/** 
 *  @file
 *  @brief   T形（T）梁截面属性使用解析公式计算类
 *  @author  yangtianxing
 *  @date    2024.03.31
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "TSectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::TSectionFormulaCalculator;

void TSectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    Real d{section.m_dimension[0]};
    Real tf{section.m_dimension[2]};
    Real tw{section.m_dimension[3]};
    Real h{section.m_dimension[1] - 0.5 * tf};
    Real hw{h - 0.5 * tf};

    property.m_id  = section.m_id;
    property.m_mId = section.m_mId;
    property.m_A   = d * tf + hw * tw;
    // Real yS = 0.0;
    // Real zS = 0.0;
    Real yC = -0.5 * hw * tw * (hw + tf) / property.m_A;
    // Real zC = 0.0;
    property.m_I1  = d * tf * tf * tf / 12.0 + tw * hw * hw * hw / 12.0 + tw * hw * (yC + 0.5 * (hw + tf)) * (yC + 0.5 * (hw + tf)) +
                     d * tf * yC * yC;
    property.m_I2  = tf * d * d * d / 12.0 + hw * tw * tw * tw / 12.0;
    property.m_I12 = 0.0;
    property.m_J   = (d * tf * tf * tf + h * tw * tw * tw) / 3.0;
    property.m_K1  = hw * tw / property.m_A;
    property.m_K2  = tf * d / property.m_A;
    property.m_NSM = section.m_nsm;
    property.m_FE  = 0.0;
    property.SetStressPoints ({-yC + 0.5 * tf,  0.0,
                               -yC + 0.5 * tf,  0.5 * d,
                               -yC - h,         0.0,
                               -yC + 0.5 * tf, -0.5 * d});
    centroid.m_x = 0.0;
    centroid.m_y = 0.0;
    centroid.m_z = 0.0;
}